.. _Tutorial: using NeurEco GUI on a Discrete Dynamic problem: Tutorial: using NeurEco GUI on a Discrete Dynamic problem ========================================================== The following section will use two test cases: * The test case :std:ref:`Temperature forecasting test case`. * The test case :std:ref:`Nonlinear oscillator test case`. These test cases can be selected directly from the template window of the GUI: .. figure:: ./images/DiscDynGUIChoice.png :width: 450 :alt: DiscDynGUIChoice :align: center Choosing the test case Temperature forecasting directly from the GUI examples Discrete Dynamic proposes various settings for the build and the evaluation. This tutorial is divided into two parts: :std:ref:`Building a Discrete Dynamic model GUI` and :std:ref:`Evaluating a discrete dynamic model in the GUI`. .. _Building a Discrete Dynamic model GUI: Building a Discrete Dynamic model in the GUI ---------------------------------------------- There are two main options to build a Discrete Dynamic model: * with a validation percentage, the validation data is chosen from the training data by NeurEco * with validation data, the validation data is set manually. For each option, the build can be done without selecting any of the advanced settings (steady state and hidden state, see :std:ref:`NeurEco Discrete Dynamic build parameters GUI`), or with these settings provided by the user. Create an empty directory (TemperatureForecasting Example), extract the :std:ref:`Temperature forecasting test case` test case data there. The GUI automatically extracts the data and creates the project in the chosen directory. The created directory contains the following files: .. figure:: ./images/TempForecastGUIContent.png :width: 300 :alt: TempForecastGUIContent :align: center Content of the test case Temperature Forecasting from the GUI The TemperetureForecasting directory is the one used by the GUI alongside the NumPy data files. The rest is used by the other NeurEco interfaces. .. note:: To create the GUI project without using the template window, create a new directory called TemperatureForecasting and copy the data NumPy files into it. Go to the **File** menu, and click **New**, then choose the **Dynamic** solution and the **Discrete Dynamic** template. Choose the name of the project and the name of the model as: TemperatureForecasting and TemperatureForecasting and click ok. .. figure:: ./images/TempForecastGUINormalChoice.png :width: 600 :alt: TempForecastGUINormalChoice :align: center Choosing the test case TemperatureForecasting directly from the GUI examples 2 The main window looks as follows at this stage: .. figure:: ./images/TempForecastGUIMainLook.png :width: 800 :alt: TempForecastGUIMainLook :align: center Main window initial look after extracting the data: test case - Temperature Forecasting Simple build without validation data ###################################### To build a model without any of the advanced settings provided and without manually setting validation data: * Provide the **Training data** * Click the **Build** button in the GUI. In this case NeurEco takes the last 30% of every provided trajectory in training data as validation data. During the build NeurEco saves the intermediate modes to the checkpoint file. In term of performance, every new model in the checkpoint is an improvement of the previous one. Note that at the end of the build, the last model in the checkpoint corresponds to the final mode. Any intermediate model can be used as if it was the final model: it can be evaluated on the new sets of data, exported, etc. Use the checkpoint slider to select a specific intermediate model. When an intermediate model is selected, the GUI updates the plot of reference vs prediction and the **Sensitivity analysis** plot (see :std:ref:`Sensitivity analysis Discrete Dynamic`). .. figure:: ./images/TempForecastGUIIntermediate.png :width: 800 :alt: TempForecastGUIIntermediate :align: center GUI operations: selecting an intermediate model: test case - Temperature Forecasting To perform a sensitivity analysis (see :std:ref:`Sensitivity analysis Discrete Dynamic`) on any intermediate model: * Switch to the **Metrics** panel * Choose an intermediate model using the checkpoint slider * Choose a data set from **Evaluation files** (the testing data for this example) * Choose the initialization (see :std:ref:`Sensitivity analysis Discrete Dynamic`) * Click on any output node in the **Network sensitivity** section (there is only one for :std:ref:`Temperature forecasting test case` test case) * The plot displays the sensitivity analysis graph as in figure below: .. figure:: ./images/TempForecastGUISensitivity.png :width: 800 :alt: TempForecastGUISensitivity :align: center GUI operations: Performing Sensitivity analysis: test case - Temperature Forecasting Simple build with validation data ###################################### For the :std:ref:`Temperature forecasting test case` test case: * Create a new model in the TemperatureForecasting project by ether: * Creating from scratch: click on **+** in front of **Models** * Cloning setting of already existing model: right click on the model name and choose **Clone** * As before, set the first year data as **Training Data** * Set the second year data as **Validation Data** * Click the **Build** button Note that although the 30% validation data is set, NeurEco will not take it into account because the **Validation Data** are provided. .. figure:: ./images/TempForecastGUIMainLook2.png :width: 600 :alt: TempForecastGUIMainLook2 :align: center Main window initial look after extracting the data: test case - Temperature Forecasting 2 As previously, any intermediate model can be used as if it was the final model: it can be evaluated on the new sets of data, exported, etc. Use the checkpoint slider to select a specific intermediate model. When an intermediate model is selected, the GUI updates the plot of reference vs prediction and the Sensitivity analysis plot (see :std:ref:`Sensitivity analysis Discrete Dynamic`). .. _Advanced build for Discrete Dynamic: Advanced build ###################################### This part uses :std:ref:`Nonlinear oscillator test case`. Create an empty directory (NonLinearOscillator Example), and extract the :std:ref:`Nonlinear oscillator test case` data there. The GUI will automatically extract the data and create the project in the chosen directory. The main window looks as follows at this stage: .. figure:: ./images/DuffingGUIMainLook.png :width: 600 :alt: DuffingGUIMainLook :align: center Main window initial look after extracting the data: test case - Non linear oscillator From the equation governing the outputs, one can see that a stationary state (see :std:ref:`NeurEco Discrete Dynamic advanced parameters GUI`) is described by the excitation set to :math:`0` and thus the corresponding output to :math:`0`: * Set **Advanced: steady input** to :math:`0` * Set **Advanced: steady output** to :math:`0` .. note:: The **Discrete Dynamic** model supports providing of only one steady state of the model. The governing equation is of the second degree, which could imply that two hidden states (see :std:ref:`NeurEco Discrete Dynamic advanced parameters GUI`) are sufficient to describe the system. Here, one more hidden state is added to take the non linearity into account: * Set **Advanced: max hidden states** to :math:`3` To build the model: * Click on the **Build** button The results on the training data: .. figure:: ./images/DuffingGUIPlot.png :width: 600 :alt: DuffingGUIPlot :align: center GUI operations: selecting an intermediate model: test case - Non linear oscillator .. _Evaluating a discrete dynamic model in the GUI: Evaluating a Discrete Dynamic model in the GUI ---------------------------------------------- There are two options to evaluate a discrete dynamic model: with and without initial conditions (see. :std:ref:`Evaluate NeurEco Discrete Dynamic model with GUI`). When using the GUI, evaluating the model without initial condition is straight forward: * Switch to the **Evaluation** panel * In **Evaluating files** section: select the data set on which to evaluate * Click the **Evaluate** button: .. figure:: ./images/TempForecastGUIEvalNoInit.png :width: 600 :alt: TempForecastGUIEvalNoInit :align: center GUI operations: evaluating an intermediate model without initial condition: test case - Temperature forecasting To provide an initial condition (recommended): * Switch to the **Evaluation** panel * In **Evaluating files** section: select the data set on which to evaluate * Click on **Initialization interval: select button**. A cursor appears on top of the plots, place the two ends of the cursor on the interval to select as initialization interval * Click the **Evaluate** button .. figure:: ./images/TempForecastGUIEvalWithInit.png :width: 600 :alt: TempForecastGUIEvalWithInit :align: center GUI operations: evaluating an intermediate model with initial condition: test case - Temperature forecasting .. note:: When providing the input and output files for evaluation, the output file is optional and in this case only the default evaluation is available. The output file can also contain less data points than the input file, for example, only the initialization interval with few time points. The **Metrics** panel allows the user to extract a set of metrics about that dataset (see. :std:ref:`Metrics Discrete Dynamic`). For the **Discrete Dynamic** template these metrics looks as shown in the figure below: .. figure:: ./images/TempForecastGUIMetrics.png :width: 800 :alt: TempForecastGUIMetrics :align: center GUI operations: Extracting the metrics: test case - Temperature Forecasting Exporting a Discrete dynamic model ------------------------------------ To export a **Discrete Dynamic** model: * Switch to the **Export** panel * (optional) Select an intermediate model to export. By default, the final model is selected. * Choose the export format: NeurEco .ernn format or FMU (requires *embed* license) .. figure:: ./images/TempForecasGUIExport.png :width: 300 :alt: TempForecasGUIExport :align: center GUI operations: Exporting a model : test case - Temperature Forecasting To create a Python script reproducing the main parts of the GUI project (see :std:ref:`Export Discrete Dynamic from the GUI to the Python API`): * Go to **Python/Export NeurEco to Python** in the menu bar of the GUI * Choose which parts of the project to export to a Python script * Select the destination where to save the script .. figure:: ./images/TempForecasGUIPython.png :width: 300 :alt: TempForecasGUIPython :align: center GUI operations: Exporting a Python script : test case - Temperature Forecasting .. warning:: To be able to use the script exported from the GUI, the NeurEco Python API package should be already installed on your computer.